#pragma once

#include <dshow.h>
#pragma include_alias( "dxtrans.h", "qedit.h" )
#define __IDxtCompositor_INTERFACE_DEFINED__

#define __IDxtAlphaSetter_INTERFACE_DEFINED__

#define __IDxtJpeg_INTERFACE_DEFINED__

#define __IDxtKey_INTERFACE_DEFINED__
#include "Qedit.h"



typedef struct Image_Cap_t
{
    int width;
    int height;
    int type;   // 0: rgb
    void* pBuf;
    int nBufLen;
}Image_Cap;


typedef void (*CAPTURE_COMPLETE)(Image_Cap* pCap,void* pPayload);


class CCamera
{
public:
    CCamera(void);
    ~CCamera(void);

    bool        IsRun();
    HRESULT    Init(HWND hWnd);
    void    Release();

    HRESULT    start();
    HRESULT    CaptureBuf( CAPTURE_COMPLETE callback, void* payload);
    HRESULT    CaptureFile(const char* strFile, CAPTURE_COMPLETE callback, void* payload);
    void    stop();

protected:
    HRESULT FindCaptureDevice(IBaseFilter ** ppSrcFilter);

    HRESULT InitFilters(HWND hWnd);

protected:
    HWND    m_hWnd;
    IVideoWindow  * g_pVW;
    IMediaControl * g_pMC;
    IMediaEventEx * g_pME;
    IGraphBuilder * g_pGraph;
    ICaptureGraphBuilder2 * g_pCapture;

    IBaseFilter *pGrabberF;
    ISampleGrabber *pGrabber;
    IBaseFilter *pNullF;
    IBaseFilter *pSrcFilter;
    AM_MEDIA_TYPE mt;

};
